package com.yh.patterns.observer.job;

/**
 * @Author:云尚
 * @Description:具体主题类
 */
public class ConcreteTeam extends Team{

    //创建战队的方法
    public ConcreteTeam(String teamName) {
        System.out.println(teamName+"战队创建成功！");
        System.out.println("++++++++++++++++++++开始战斗吧：++++++++++++++++++++");
        this.teamName=teamName;
    }

    @Override
    public void notify(String name) {
        System.out.println(this.teamName+"战队紧急通知:盟友"+name+"遭受攻击了");
        //遍历观察者集合，调用每一个盟友（自己除外）的支援方法
        for (Observer player : players) {
            if(!(player.getName().equalsIgnoreCase(name))){
                player.help();
            }
        }
    }
}
